<template>
  <div class="home">
    <div><h1>管理主页</h1></div>
    <div>
          <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
            <el-tab-pane label="商家列表" name="first"></el-tab-pane>
            <el-tab-pane label="产品列表" name="second"></el-tab-pane>
            <el-tab-pane label="重置密码" name="third"></el-tab-pane>
            <el-tab-pane label="管理员列表" name="fourth"></el-tab-pane>
          </el-tabs>
    </div>
    <div>
        <router-view/>
    </div>

  </div>
</template>

<script>
// @ is an alias to /src

export default {
  name: 'Home',
  data() {
      return {
        user: null,
        activeName: 'first',

      }
  },
  mounted() {
      let token = window.sessionStorage.getItem('token')
      if(token == null) {
          this.$router.push('/login')
          return
      }
      // 保存当前登录用户信息
      this.user = window.sessionStorage.getItem('user')
      

  },
  methods: {
        handleClick(tab, event) {
            console.log(this.activeName, tab, event);
            if(this.activeName == 'first') {
                this.$router.push('/index/seller')
            }
            else if(this.activeName == 'second') {
                console.log('second');
                this.$router.push('/index/product')
            }
            else if(this.activeName == 'third') {
                console.log('third');
                this.$router.push('/index/reset')
            }
            else if(this.activeName == 'fourth') {
                console.log('second');
                this.$router.push('/index/admin')
            }
        }
  }

}
</script>
